package com.google.code.sms.android.util;

import android.app.Activity;

/**
 * @author Sindre Mehus
 */
public abstract class SilentBackgroundTask<T> extends BackgroundTask<T> {

    public SilentBackgroundTask(Activity activity) {
        super(activity);
    }

    @Override
    public void execute() {
        Thread thread = new Thread() {
            @Override
            public void run() {
                try {
                    final T result = doInBackground();

                    getHandler().post(new Runnable() {
                        public void run() {
                            done(result);
                        }
                    });

                } catch (final Throwable t) {
                    getHandler().post(new Runnable() {
                        public void run() {
                            error(t);
                        }
                    });
                }
            }
        };
        thread.start();
    }

    @Override
    public void updateProgress(int messageId) {
    }

    @Override
    public void updateProgress(String message) {
    }
}
